﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using MayhemWpf.UserControls;
using CommandMgr.Sdk;

namespace CommandEvent
{
    /// <summary>
    /// Interaction logic for CommandConfig.xaml
    /// </summary>
    public partial class CommandConfig : WpfConfiguration
    {
        public string Command
        {

            get;

            private set;

        }


        public override void OnLoad()
        {
            CommandMgr.Sdk.CommandMgr commMgr = new CommandMgr.Sdk.CommandMgr(CommandServiceConfig.Url());
            List<Command> commands = commMgr.ListCommands();
            foreach (Command comm in commands)
                comboBox1.Items.Add(comm.Name);
            if (!string.IsNullOrEmpty(this.Command))
                comboBox1.Text = this.Command;
        }

        public override string Title { get { return "Command"; } }

        public override void OnSave()
        {
            Command = comboBox1.Text.Trim();
        }


        public CommandConfig(string command)
        {
            this.Command = command;
            CanSave = true;
            InitializeComponent();
        }
    }
}
